package com.jingdianjichi.auth.application.context;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * LoginContextHolder 类
 *
 * @author 熊苏鹏1
 * @date 2025/3/10 12:56
 * @description
 */
public class LoginContextHolder {
    private static final   InheritableThreadLocal<Map<String,Object>> THREAD_LOCAL = new InheritableThreadLocal<>();
     public static void set(String key,Object value){
        getThreadLocal().put(key,value);
    }
    public static Object get(String key){
        return getThreadLocal().get(key);
    }
    public static String getLoginId(){
         System.out.println(getThreadLocal());
        return (String) get("loginId");
    }
    public   static Map<String,Object> getThreadLocal(){
        Map<String, Object> map = THREAD_LOCAL.get();
        if (map == null){
            map = new ConcurrentHashMap<>();
            THREAD_LOCAL.set(map);
        }
        return map;
    }


}
